<?php
namespace Oa\Controller;
use Think\Controller;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/26
 * Time: 16:21
 * @author: yfl
 * @QQ: 554665488
 * @description:
 * @time:
 */
abstract class BaseController extends Controller
{
    /**
     * @description:错误返回
     * @author 554665488@qq.com(2017年3月01日 08:04:56)
     * @param string $msg
     * @param array $fields
     */
    protected function ajaxError($msg = '', $fields = array())
    {
        header('Content-Type:application/json; charset=utf-8');
        $data = array('status' => 'error', 'msg' => $msg, 'fields' => $fields);
        echo json_encode($data);
        exit;
    }

    /**
     * @author: yfl
     * @QQ: 554665488
     * @description: 成功返回
     * @time: 2017-7-26 16:22:56
     * @param $msg
     * @param array $_data
     */
    protected function ajaxSuccess($msg, $_data = array())
    {
        header('Content-Type:application/json; charset=utf-8');
        $data = array('status' => 'success', 'msg' => $msg, 'data' => $_data);
        echo json_encode($data);
        exit;
    }
}